package com.qidian.tcba.admin.api.controller;


import com.qidian.tcba.admin.model.dto.parkLot.ParkLotManageListDTO;
import com.qidian.tcba.admin.model.dto.parkLotManage.*;
import com.qidian.tcba.admin.model.query.NearParkLotQueryDTO;
import com.qidian.tcba.admin.model.query.ParkLotQueryDTO;
import com.qidian.tcba.admin.service.ParkLotService;
import com.qidian.tcba.utils.JSONResult;
import com.qidian.tcba.utils.result.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 停车场信息表 前端控制器
 * </p>
 *
 * @author 冯永龙
 * @since 2021-07-06
 */
@RestController
@RequestMapping("/parkLot")
@Api(tags ="停车场")
public class ParkLotController {
    private final ParkLotService parkLotService;

    public ParkLotController(ParkLotService parkLotService) {
        this.parkLotService = parkLotService;
    }

    @ApiOperation("经营者，根据名字模糊查询获取停车场列表")
    @GetMapping("/getListByName/{name}")
    public JsonResult getListByName(@PathVariable("name") String name) {
        List<ParkLotManageListDTO> parkLotList = parkLotService.getParkLotListByName(name);
        return JsonResult.success().data("rows",parkLotList);
    }

    @ApiOperation("经营者，停车场管理")
    @GetMapping("/getManage/{orgId}")
    public JsonResult getParkLotManageList(@PathVariable int orgId){
        List<ParkLotManageListDTO> list = parkLotService.getParkLotManageList(orgId);
        return JsonResult.success().data("rows",list);
    }

    @ApiOperation("管理员，停车场管理")
    @PostMapping("/getManageParkList")
    public JSONResult<List<ParkLotRecordManageResultDTO>> getParkLotManageList(@RequestBody ParkLotManageDTO parkLotManageDTO){
        List<ParkLotRecordManageResultDTO> parkLotManageList = parkLotService.getParkLotManageList(parkLotManageDTO);
        return new JSONResult<>(parkLotManageList,200,"成功");
    }

    @ApiOperation("停车场查询")
    @PostMapping("/query")
    public JSONResult<List<ParkLotQueryResultDTO>> getQueryResultParkLot(@RequestBody ParkLotQueryDTO parkLotQueryDTO){
        List<ParkLotQueryResultDTO> parkLotQueryResultList = parkLotService.getParkLotQueryResultList(parkLotQueryDTO);
        return new JSONResult<>(parkLotQueryResultList, 200,"成功");
    }

    @ApiOperation("查询附近停车场")
    @PostMapping("/queryNearParkLot")
    public JSONResult<List<ParkLotQueryResultDTO>> getNearParkLot(@RequestBody NearParkLotQueryDTO nearParkLotQueryDTO){
        List<ParkLotQueryResultDTO> nearParkLot = parkLotService.getNearParkLot(nearParkLotQueryDTO);
        return new JSONResult<>(nearParkLot, 200, "成功");
    }
}

